package com.rp.infopub.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.rp.common.utils.RpUtil;
import com.rp.infopub.dao.ArticleDao;
import com.rp.infopub.po.Article;
import com.rp.log.annotation.RpLog;

@Service
@Transactional
public class ArticleService {

	@Autowired
	private ArticleDao articleDao;
	
	/**
	 * 添加文章
	 * @param article
	 * @return
	 */
	@RpLog(desc="添加文章")
	public String saveArticle(Article article){
		article.setCreateDate(RpUtil.getCurrentDatetime());
		return (String) articleDao.save(article);
	}
	
	/**
	 * 删除文章
	 * @param articleId
	 */
	@RpLog(desc="删除文章")
	public void deleteArticle(String articleId){
		articleDao.delete(articleId);
	}
	
	/**
	 * 更新文章
	 * @param article
	 */
	@RpLog(desc="更新文章")
	public void updateArticle(Article article){
		article.setUpdateDate(RpUtil.getCurrentDatetime());
		articleDao.update(article);
	}
	
	
	
	public ArticleDao getArticleDao() {
		return articleDao;
	}
	
}
